<template>
  <mt-preview ref="MtPreviewRef" @on-event-call-back="onEventCallBack"></mt-preview>
</template>
<script setup lang="ts">
import { MtPreview } from 'maotu'
import { onMounted, ref, toRef } from 'vue';
import { useRoute } from "vue-router";
import { ElMessage } from 'element-plus';
import { storeToRefs } from 'pinia'
import { useMaoxyStore } from '@/stores/maoxy'

let route = useRoute();
let maoxyStore = useMaoxyStore();
let { jsonData } = storeToRefs(maoxyStore);

const MtPreviewRef = ref<InstanceType<typeof MtPreview>>();
const onEventCallBack = (type: string, item_id: string) => {
    if (type == 'test-dialog') {
		ElMessage.success(`获取到了id:${item_id}`);
	}
};

onMounted(() => {
    const res = MtPreviewRef.value?.setImportJson(jsonData.value);
    if (res) {
        console.log('加载成功');
    } 
    else {
        console.log(res, '加载失败');
    }
});
</script>
<style>

</style>
